package pathservice

import (
	"fmt"
	"gmap-backend/internal/config"
	"gmap-backend/internal/server/vo"
	"gmap-backend/internal/util/pathutil"
)

func RecognizePath(appConfig *config.AppConfig, req *vo.PathReq, bins [][]byte) *vo.RecognizedPathResp {
	parseResult := pathutil.ParseValidPath(req.Path, req.CtxDir)
	if !parseResult.Succ {
		panic(fmt.Sprintf("路径不存在：\r\n%s", req.Path))
	}
	return &vo.RecognizedPathResp{
		Path:   parseResult.ValidPath,
		IsFile: parseResult.File,
		IsDir:  parseResult.Dir,
	}
}
